<%@page contentType="text/html;charset=utf-8" isELIgnored="false"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE html>
<html>
<head>
    <title>上传</title>
    <link href="/fileCenter/swfupload/css/default.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="/fileCenter/swfupload/js/swfupload.js"></script>
	<script type="text/javascript" src="/fileCenter/swfupload/js/swfupload.queue.js"></script>
	<script type="text/javascript" src="/fileCenter/swfupload/js/fileprogress.js"></script>
	<script type="text/javascript" src="/fileCenter/swfupload/js/handlers.js"></script>
	<script src="/fileCenter/codebase/dhtmlx.js" type="text/javascript"></script>
	<script type="text/javascript">
		var swfu;

		window.onload = function() {
			var settings = {
				flash_url : "/fileCenter/swfupload/swfupload.swf",
				upload_url: "/fileCenter/upload?JSESSIONID=<%=session.getId() %>&uid=${loginUser.id}",//上传地址
				file_size_limit : "100 MB",
				file_types : "*.*",
				file_types_description : "All Files",
				file_upload_limit : 100,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : "fsUploadProgress",
					cancelButtonId : "btnCance",
					submitButtonId : "btnSubmit"
				},
				debug: false,

				// Button settings
				button_image_url: "/fileCenter/swfupload/images/TestImageNoText_65x29.png",
				button_width: "65",
				button_height: "29",
				button_placeholder_id: "spanButtonPlaceHolder",
				button_text: '<span class="theFont">选择文件</span>',
				button_text_style: ".theFont { font-size: 14;}",
				button_text_left_padding: 3,
				button_text_top_padding: 5,
				
				// The event handler functions are defined in handlers.js
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
	     };
	     
	     function authSelfFileSeccCallbacck() {
	     	window.parent.loadGrid();
	     	window.parent.docLayout.cells('b').collapse();
	     }
	     
	     function emptyQueue() {
	     	var url = "/fileCenter/file/deleteUnAuth.do?";
	     	var fileInfoEls = document.getElementsByName("fileInfo");
	     	for(var i=0;i<fileInfoEls.length;i++) {
	     		url = url + "fid=" + fileInfoEls[i].value;
	     	}
	     	dhtmlxAjax.get(url, function(loader){
	     		window.parent.docLayout.cells('b').collapse();
	     		window.parent.docLayout.cells('b').expand();
            });
	     }
	</script>
</head>
<body>
<div id="content">
	<form id="form" action="/fileCenter/file/authSelfFiles.do" method="post" target="RSIFrame">
		<div class="fieldset flash" id="fsUploadProgress">
			<logic:iterate id="file" name="files" indexId="index">
				<div class="progressWrapper" id="SWFUpload_0_0" style="opacity: 1;">
					<div class="progressContainer blue">
						<a class="progressCancel" href="#" style="visibility: hidden;"> </a>
						<div class="progressName">${file.uploadName}</div>
						<div class="progressBarStatus">上传完成...</div>
						<div class="progressBarComplete" style=""></div>
						<input type="hidden" name="fileInfo" value="${file.id}">
					</div>
				</div>
			</logic:iterate>
		</div>
		
		<div class="btn_group">
			<span id="spanButtonPlaceHolder"></span>
			<logic:empty name="files">
				<input type="submit" disabled="disabled" onclick="swfu.cancelQueue();" value="提交文件" id="btnSubmit">
			</logic:empty>
			<logic:notEmpty name="files">
				<input type="submit" onclick="swfu.cancelQueue();" value="提交文件" id="btnSubmit">
			</logic:notEmpty>
			<input id="btnCance" type="submit" value="取消上传" disabled="disabled" />
			<input type="button" value="清空上传列表" onclick="emptyQueue();" />
			<span id="divStatus" style="display:none;">已上传0个文件</span>
		</div>
	</form>
	
	<iframe id="RSIFrame" name="RSIFrame" style="width:0px; height:0px; border: 0px" src="/fileCenter/blank.htm"></iframe>
</div>
</body>
</html>